#ifndef BSP_USART_H
#define BSP_USART_H

#include "stdint.h"
#include "main.h"
#include "stdlib.h"
#include "string.h"

#define USART_MAX_NUM 3
#define USART_RXBUFF_MAX_SIZE 256

typedef void (*USART_Callback)();
typedef enum
{
    USART_TRANSFER_NONE = 0,
    USART_TRANSFER_BLOCKING,
    USART_TRANSFER_IT,
    USART_TRANSFER_DMA,
} USART_TRANSFER_MODE_e;

typedef struct usart
{
    uint8_t recv_buff[USART_RXBUFF_MAX_SIZE];
    uint8_t recv_buff_size;
    UART_HandleTypeDef* USARTx;
    USART_Callback usart_callback;
    void* id;
} USARTInstance;

typedef struct 
{
    uint8_t recv_buff_size;
    UART_HandleTypeDef* USARTx;
    USART_Callback usart_callback;
    void* id;
} USART_Init_Config_s;

USARTInstance* USARTInit(USART_Init_Config_s* _config);

void USARTSend(USARTInstance* _instance, uint8_t* data, 
               uint16_t size, USART_TRANSFER_MODE_e mode);


#endif 
